import request from '@/utils/request'

// 查询生产计划列表
export function listPlan(query) {
  return request({
    url: '/ldzl-sc/sc/productionPlan/list',
    method: 'get',
    params: query
  })
}

// 分解生产计划
export function decomposePlan(planCode) {
  return request({
    url: '/ldzl-sc/sc/productionPlan/decompose/' + planCode,
    method: 'post'
  })
}

// 查询产品列表
export function listProduct(query) {
  return request({
    url: '/basic/product/list',
    method: 'post',
    data: query
  })
}

// 根据产品ID查询BOM列表
export function listBomByProduct(query) {
  return request({
    url: '/ldzl-basic/bmd/list',
    method: 'post',
    data: query
  })
}

// 根据生产计划查询工单列表
export function getWorkOrdersByPlan(planCode) {
  return request({
    url: '/ldzl-sc/workOrder/list',
    method: 'get',
    params: { planCode }
  })
  
} 
/**
 * 根据生产计划编号获取BOM信息
 * @param {string} planCode
 * @returns
 */
export function getBomByPlanCode(planCode) {
  return request({
    url: '/ldzl-sc/sc/bom/plan/' + planCode,
    method: 'get'
  });
}

// 删除生产计划
export function delProductionPlan(planId) {
  return request({
    url: '/ldzl-sc/sc/productionPlan/' + planId,
    method: 'delete'
  })
}